package 力扣日常刷题.木22二月.第09天215;

/**
 * @author 帅小伙
 * @date 2022/2/15
 * @description
 */
public class Demo67搜索二维矩阵II {

    public boolean searchMatrix(int[][] matrix, int target) {
        int x  = matrix.length,y = matrix[0].length ;
        int curX = 0,curY = y - 1;
        while (curX < x && curY >= 0){
            if(matrix[curX][curY] == target) return true;
            else if(matrix[curX][curY] < target) curX++;
            else curY -- ;
        }
        return false;
    }
}
